set(STATS_SERVER stats_server)
set(STATS_SERVER_SRCS stats_server.cpp ${CMAKE_SOURCE_DIR}/common/daemon/daemonize.cpp ${CMAKE_SOURCE_DIR}/common/logging/logging.cpp)
set(STATS_SERVER_SRCS ${STATS_SERVER_SRCS} ${CMAKE_SOURCE_DIR}/components/network/setup_mcast.cpp)

PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
set(STATS_SERVER_SRCS ${STATS_SERVER_SRCS} ${PROTO_SRCS})
set(STATS_SERVER_SRCS ${STATS_SERVER_SRCS} Stats_ServerOptions.cpp)
set(STATS_SERVER_SRCS ${STATS_SERVER_SRCS}
        components/network/recv_service_request.cpp
        components/network/send_enc_pb_message.cpp
        components/protocol/create_enc_service_reply.cpp
        components/protocol/decode_enc_pb_request.cpp
        components/protocol/server_send_reply.cpp
        components/protocol/recv_client_request.cpp
        components/protocol/stats_server_processor.cpp
        components/service/mcast_service_process.cpp
        components/utils/stats_container.cpp
        components/application/stats_mcast_server.cpp
)
set(STATS_SERVER_SRCS ${STATS_SERVER_SRCS}
        ${CMAKE_SOURCE_DIR}/patterns/handlers.cpp
        ${CMAKE_SOURCE_DIR}/components/utils/linear_flight_timer.cpp
        ${CMAKE_SOURCE_DIR}/components/encrypt/utils.cpp
        ${CMAKE_SOURCE_DIR}/components/encrypt/aes_service.cpp
        ${CMAKE_SOURCE_DIR}/components/encrypt/blowfish_service.cpp
)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/stats_server)
add_executable(${STATS_SERVER} ${STATS_SERVER_SRCS})
SET_TARGET_PROPERTIES(${STATS_SERVER} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(${STATS_SERVER}  ${CONFIG_LIB_NAME} ${CRYPTOPP_LIBRARIES} ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${PTHREAD_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}
  ${GLOG_LIBRARIES} ${PROTOBUF_LIBRARY})

INSTALL(TARGETS ${STATS_SERVER} DESTINATION local/bin)
